SiteUtils.admin = liwe.module ( 'SiteUtils.admin', null, "Site Utils" );

SiteUtils.admin.init = function ()
{
	var _acts = [
			{ func: function () { SiteUtils.admin.clean_html_form ( 'system-content' ); }, label: 'Test Clean HTML', 'default': true }
		];

	SiteUtils.admin.register ( _acts );
};

SiteUtils.admin.clean_html_form = function ( dest_div )
{
	var f = new liwe.form.instance ( "clean_html_test_form" );

	f.textarea ( { "label" : "Original HTML", name: "orig_html", rows: 10, cols: 80, nonl: true } );
	f.button ( { "value" : "Convert", onclick: "SiteUtils.admin._clean_html_test()" } );
	f.textarea ( { "label" : "Result HTML", name: "result_html", rows: 30, cols: 80 } );
	f.workspace ( { "name" : "result_html_view" } );

	f.set ( dest_div );
};

SiteUtils.admin._clean_html_test = function ()
{
	var f = liwe.form.get ( "clean_html_test_form" );
	var txt = f.get_value ( "orig_html" );

	SiteUtils.clean_html ( txt, function ( v )
		{
			f.set_value ( "result_html", v [ 'clean_html' ] );
			$( "result_html_view", v [ 'clean_html' ] );
		}
	);
	
};
